package net.wangds.auth.grant.repo.rdbms;

import net.wangds.auth.grant.entity.GeneralGrantEntity;
import net.wangds.auth.module.ResourceSchemaEnum;
import net.wangds.jpa.repository.RemovableRepo;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface GrantJpaRepo extends RemovableRepo<GeneralGrantEntity> {

    List<GeneralGrantEntity> findByOwnerId(String ownerId);

    List<GeneralGrantEntity> findByOwnerIdAndSchema(String ownerId, ResourceSchemaEnum schema, Sort sort);

    Optional<GeneralGrantEntity> findByOwnerIdAndResId(String ownerId, String resId);

    List<GeneralGrantEntity> findByOwnerIdAndAction(String ownerId, int action);

    List<GeneralGrantEntity> findByOwnerIdAndSchemaAndAction(String id, ResourceSchemaEnum menu, int action);
}
